package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.SaleList;
import com.atguigu.jxc.service.SaleListGoodsService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/saleListGoods")
public class saleListGoodsContorller {

    @Autowired
    private SaleListGoodsService saleListGoodsService;

    @RequestMapping("/save")
    @RequiresPermissions("销售出库")
    public ServiceVO save (SaleList saleList,String saleListGoodsStr){
        return saleListGoodsService.save(saleList,saleListGoodsStr);
    }

    @RequestMapping("list")
    @RequiresPermissions(value={"销售单据查询","客户统计"},logical= Logical.OR)
    public Map<String,Object> list (String saleNumber, Integer customerId, Integer state, String sTime, String eTime){
        return saleListGoodsService.list(saleNumber,customerId,state,sTime,eTime);
    }

    @RequestMapping("/goodsList")
    @RequiresPermissions(value={"销售单据查询","客户统计"},logical= Logical.OR)
    public Map<String,Object> goodsList (Integer saleListId){
        return saleListGoodsService.goodsList(saleListId);
    }

    @RequestMapping("/delete")
    @RequiresPermissions(value = "销售单据查询")
    public ServiceVO delete (Integer saleListId){ return saleListGoodsService.delete(saleListId); }

    @RequestMapping("/updateState")
    @RequiresPermissions(value = "供应商统计")
    public ServiceVO updateState (Integer saleListId){
        return saleListGoodsService.updateState(saleListId);
    }

    @RequestMapping("/count")
    @RequiresPermissions(value="商品销售统计")
    public String count (String sTime,String eTime,Integer goodsTypeId,String codeOrName){
        return saleListGoodsService.count(sTime,eTime,goodsTypeId,codeOrName);
    }

    @RequestMapping("/getSaleDataByDay")
    @RequiresPermissions(value = "按日统计分析")
    public String getSaleDataByDay (String sTime,String eTime){
        return saleListGoodsService.getSaleDataByDay(sTime,eTime);
    }


    @RequestMapping("/getSaleDataByMonth")
    @RequiresPermissions(value = "按月统计分析")
    public String getSaleDataByMonth (String sTime,String eTime){
        return  saleListGoodsService.getSaleDataByMonth(sTime,eTime);
    }





}
